package soccer.view;

import java.awt.event.ActionListener;
import java.util.List;
import java.util.Map;

import javax.swing.DefaultComboBoxModel;
import javax.swing.JPanel;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JButton;

import sun.util.calendar.JulianCalendar;
import javax.swing.JTextField;

public class AddTeamMatchPanel extends JPanel {
	private JComboBox comboBoxHomeTeam;
	private JLabel lblHomeTeamLabel;
	private JLabel lblWeekLabel;
	private JComboBox comboBoxWeek;
	private JLabel lblAwayTeamLabel;
	private JComboBox comboBoxAwayTeam;
	private JButton btnAddMatch;
	private JLabel lblWriteDate;
	private JTextField textFieldWriteDate;
	private JButton btnBackToAdminOptionsSystem;
	
	/**
	 * Create the panel.
	 */
	public AddTeamMatchPanel() {
		setLayout(null);
		
		comboBoxHomeTeam = new JComboBox();
		comboBoxHomeTeam.setBounds(55, 82, 63, 20);
		add(comboBoxHomeTeam);
		
		lblHomeTeamLabel = new JLabel("Home Team");
		lblHomeTeamLabel.setBounds(55, 57, 63, 14);
		add(lblHomeTeamLabel);
		
		comboBoxAwayTeam = new JComboBox();
		comboBoxAwayTeam.setBounds(262, 82, 63, 20);
		add(comboBoxAwayTeam);
		
		lblAwayTeamLabel = new JLabel("Away Team");
		lblAwayTeamLabel.setBounds(262, 57, 63, 14);
		add(lblAwayTeamLabel);
		
		comboBoxWeek = new JComboBox();
		comboBoxWeek.setBounds(177, 82, 28, 20);
		add(comboBoxWeek);
		
		lblWeekLabel = new JLabel("Week");
		lblWeekLabel.setBounds(174, 57, 46, 14);
		add(lblWeekLabel);
		
		btnAddMatch = new JButton("Add Match");
		btnAddMatch.setBounds(119, 266, 89, 23);
		add(btnAddMatch);
		
		lblWriteDate = new JLabel("Write Date");
		lblWriteDate.setBounds(55, 222, 63, 14);
		add(lblWriteDate);
		
		textFieldWriteDate = new JTextField();
		textFieldWriteDate.setBounds(119, 219, 86, 20);
		add(textFieldWriteDate);
		textFieldWriteDate.setColumns(10);
		
		btnBackToAdminOptionsSystem = new JButton("Back to System");
		btnBackToAdminOptionsSystem.setBounds(215, 266, 110, 23);
		add(btnBackToAdminOptionsSystem);
		
		
		
	}
	public void addCoachBackToSystem(ActionListener l){
		btnBackToAdminOptionsSystem.addActionListener(l);
	}

	
	public JButton getBtnBackToAdminOptionsSystem() {
		return btnBackToAdminOptionsSystem;
	}
	public void setBtnBackToAdminOptionsSystem(JButton btnBackToAdminOptionsSystem) {
		this.btnBackToAdminOptionsSystem = btnBackToAdminOptionsSystem;
	}
	public void addMatchButtonAction(ActionListener l){
		btnAddMatch.addActionListener(l);
	}
	public void fillComboBoxWithTeams(List<Map> teamsName){
	    Object[] items = new Object[teamsName.size()+1];
	       items[0] = "no team";
	    for(int i = 1; i < items.length; i++){
	    	Map item = teamsName.get(i-1);
	    	items[i] = item.get("teamName");
	    }
		DefaultComboBoxModel model = new DefaultComboBoxModel(items);
		comboBoxHomeTeam.setModel(model);
		
		
	}
	public void fillComboBoxWithAwayTeams(List<Map> teamsName){
	    Object[] items = new Object[teamsName.size()+1];
	       items[0] = "no team";
	    for(int i = 1; i < items.length; i++){
	    	Map item = teamsName.get(i-1);
	    	items[i] = item.get("teamName");
	    }
		DefaultComboBoxModel model = new DefaultComboBoxModel(items);
		
		comboBoxAwayTeam.setModel(model);
		
	}
	public void fillComboBoxWithWeeks(List<Integer> week ){
		Object []items=new Object[week.size()+1];
		items[0]=1;
		for(int i=1;i<items.length;i++){
			items[i]=i+1;
		}
		DefaultComboBoxModel model=new DefaultComboBoxModel(items);
		comboBoxWeek.setModel(model);
	}
	public  Object getSelectedHomeTeamFromComboBox(){
		Object selectedItem = comboBoxHomeTeam.getSelectedItem();
		return selectedItem;
	}
	public  Object getSelectedAwayTeamFromComboBox(){
		Object selectedItem = comboBoxAwayTeam.getSelectedItem();
		return selectedItem;
	}
	public Object getSelectedWeekFromComboBox(){
		Object selectedItem=comboBoxWeek.getSelectedItem();
		return selectedItem;
	}
	public JComboBox getComboBoxHomeTeam() {
		return comboBoxHomeTeam;
	}

	public void setComboBoxHomeTeam(JComboBox comboBoxHomeTeam) {
		this.comboBoxHomeTeam = comboBoxHomeTeam;
	}

	public JLabel getLblHomeTeamLabel() {
		return lblHomeTeamLabel;
	}

	public void setLblHomeTeamLabel(JLabel lblHomeTeamLabel) {
		this.lblHomeTeamLabel = lblHomeTeamLabel;
	}

	public JLabel getLblWeekLabel() {
		return lblWeekLabel;
	}

	public void setLblWeekLabel(JLabel lblWeekLabel) {
		this.lblWeekLabel = lblWeekLabel;
	}

	public JComboBox getComboBoxWeek() {
		return comboBoxWeek;
	}

	public void setComboBoxWeek(JComboBox comboBoxWeek) {
		this.comboBoxWeek = comboBoxWeek;
	}

	public JLabel getLblAwayTeamLabel() {
		return lblAwayTeamLabel;
	}

	public void setLblAwayTeamLabel(JLabel lblAwayTeamLabel) {
		this.lblAwayTeamLabel = lblAwayTeamLabel;
	}

	public JComboBox getComboBoxAwayTeam() {
		return comboBoxAwayTeam;
	}

	public void setComboBoxAwayTeam(JComboBox comboBoxAwayTeam) {
		this.comboBoxAwayTeam = comboBoxAwayTeam;
	}

	public JButton getBtnAddMatch() {
		return btnAddMatch;
	}

	public void setBtnAddMatch(JButton btnAddMatch) {
		this.btnAddMatch = btnAddMatch;
	}

	public JLabel getLblWriteDate() {
		return lblWriteDate;
	}

	public void setLblWriteDate(JLabel lblWriteDate) {
		this.lblWriteDate = lblWriteDate;
	}

	public JTextField getTextFieldWriteDate() {
		return textFieldWriteDate;
	}

	public void setTextFieldWriteDate(JTextField textFieldWriteDate) {
		this.textFieldWriteDate = textFieldWriteDate;
	}
	
}
